package edu.gyc.mysystem.controller;

import edu.gyc.mysystem.dao.RoleMapper;
import edu.gyc.mysystem.dao.UserMapper;
import edu.gyc.mysystem.service.RoleService;
import edu.gyc.mysystem.vo.PermissionVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/perm")
public class PermissionController {
    @Autowired
    RoleService roleService;
    @Autowired
    UserMapper userMapper;

    @Autowired
    RoleMapper roleMapper;

    @RequestMapping("/query")
    public String userquery(Model model) {

        return "/admin/userperms";
    }
    @RequestMapping("/queryperms")
    public String userPerms(Integer id, Model model) {
        List<PermissionVo> permissionVos = roleService.getUserPermissionByUid(id);
        String username=userMapper.selectByPrimaryKey(id).getUsername();
        model.addAttribute("perms", permissionVos);
        model.addAttribute("username", username);
        return "/admin/userperms";
    }
}
